package com.tarim.streetdance.service.impl;

import com.tarim.streetdance.mapper.TypeMapper;
import com.tarim.streetdance.model.Type;
import com.tarim.streetdance.service.TypeService;
import com.tarim.streetdance.vo.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TypeServiceImpl implements TypeService {

    @Autowired
    private TypeMapper typeMapper;

    @Override
    public List<Type> selectAll(Type type) {
        return typeMapper.selectAll(type);
    }

    @Override
    public PageBean<Type> selectWithPageBean(PageBean<Type> pageBean, Type type) {
        type.addExtField("pageIndex", pageBean.getPageIndex());
        type.addExtField("pageSize", pageBean.getPageSize());
        List<Type> list = typeMapper.selectWithPageBean(type);
        Long count = typeMapper.selectWithPageBeanCount(type);
        pageBean.setTotalCount(count);
        pageBean.setData(list.toArray());
        return pageBean;
    }
}